<template>
    
    <div>
        <div class="erwei">
			<img :src="erweima" alt="">
		</div>
		<svg class="icon" aria-hidden="true">
			<use xlink:href="#icon-wechat_pay"></use>
		</svg>

        <h4>使用微信进行支付</h4>

        <el-descriptions :data="orderxq" title="用户信息">
            <el-descriptions-item label="订单号" prop="order_id">{{orderxq.order_id}}</el-descriptions-item>
            <el-descriptions-item label="创建时间">{{orderxq.create_time}}</el-descriptions-item>
            <el-descriptions-item label="产品名称">{{orderxq.orderDetail[0].productName}}</el-descriptions-item>
            <!-- <el-descriptions-item label="备注">
            <el-tag size="small">学校</el-tag>
            </el-descriptions-item> -->
            <el-descriptions-item label="商品描述">{{orderxq.orderDetail[0].description}}</el-descriptions-item>
            <el-descriptions-item label="购买数量">{{orderxq.orderDetail[0].quantity}}</el-descriptions-item>
            <el-descriptions-item label="购买用户">{{orderxq.user_nickname}}</el-descriptions-item>
            <el-descriptions-item label="手机号">{{orderxq.user_phone}}</el-descriptions-item>
            <el-descriptions-item label="总价格">{{orderxq.total_fee}}</el-descriptions-item>
        </el-descriptions>
    </div>
</template>

<script>
import * as api from '../../../../api/vipdd'
import qrCode from "qrcode";


export default {
    data() {
        return{
            order_id:'',
            // 订单详情
            orderxq:[],
            // 二维码地址
            erweima:''
        }
    },

    created(){
        let {order_id} = this.$route.query
        this.order_id = order_id

        if(!order_id){
            $alert('订单已取消,请重新下单','提示',{
                confirmButtonText:'确定',
                callback:(action)=>{
                    this.$router.go(-1)
                }
            })
        }

        Promise.all([api.hqddxq(order_id),api.fqpay(order_id)])
        .then((res)=>{
            console.log('订单详情',res)
            this.orderxq = res[0].data.data

            let payurl = res[1].data
            if(payurl.state){
                let ewmurl = payurl.code_url

                qrCode.toDataURL(ewmurl,(err,img)=>{
                    // console.log(img);
                    this.erweima = img
                })
            }
        })


        
        this.smallddq = setInterval(()=>{
            api.thisddzt(this.order_id)
        .then((res)=>{
            console.log(res);
            if(res.data.state){
                this.$router.push('/payment/paysuccess')
            }
        })
        },2000)
    }
}
</script>